﻿using B.S.Packaged.Domain.Tree;
using B.S.Packaged.ErrorCode;
using B.S.Packaged.WebAPI.Read.Application.Command.Workshop;
using B.S.Packaged.WebAPI.Read.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Packaged.WebAPI.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WorkshopController : ControllerBase
    {

        private readonly IMediator mediator;

        public WorkshopController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 显示车间列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<Domain.Tree.Workshop>>> Handle([FromQuery]GetWorkshopCommand request)
        {
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
